package marmalius;

public class MagicOnItem {

    public void MageItems(int castSpell, int castOnItem, int castOnSlot, int ID) {
        client p = (client) PlayerHandler.getInstance().getPlayer(ID);

        if ((p.playerName != null || p.playerName != "null")) {
            p.barChange = true;
            p.barTimer = 3;
            p.sidebarChangeTimer = 0;
            p.sidebarChange = 6;
            p.sidebarChanging = true;
            if (castSpell == 1162) // Low Alch
            {
                if (p.HasFireStaff()) {
                    if (!p.playerHasItemAmount(561, 1)) {
                        p.sendMessage("You do not have 1 nature.");
                    }
                    if (p.playerHasItemAmount(561, 1)) {
                        if (p.playerLevel[6] >= 21) {
                            p.deleteItem(castOnItem, castOnSlot, 1);
                            p.deleteItem(561, p.getItemSlot(561), 1);
                            p.addItem(995, 100);
                            p.addSkillXP((5 * p.playerLevel[6]), 6);
                            p.startAnimation(712);
                            p.gfx100(112);
                            p.frame174(223, 050, 000);
                            p.actionTimer = 4;
                            p.sidebarChangeTimer = 2;
                            p.sidebarChange = 6;
                            p.sidebarChanging = true;
                        } else if (p.playerLevel[6] <= 54) {
                            p.sendMessage("You need 21 magic to cast this.");
                        }
                     
                    }
                } else if (!p.HasFireStaff()) {
                    if (!p.playerHasItemAmount(561, 1)
                            && !p.playerHasItemAmount(554, 3)) {
                        p.sendMessage("You do not have 1 nature and 3 fires.");
                    }
                    if (p.playerHasItemAmount(561, 1)
                            && p.playerHasItemAmount(554, 3)) {
                        if (p.playerLevel[6] >= 21) {
                            p.deleteItem(castOnItem, castOnSlot, 1);
                            p.deleteItem(561, p.getItemSlot(561), 1);
                            p.deleteItem(554, p.getItemSlot(554), 3);
                            p.addItem(995, 100);
                            p.addSkillXP((5 * p.playerLevel[6]), 6);
                            p.startAnimation(713);
                            p.gfx100(113);
                            p.frame174(223, 050, 000);
                            p.actionTimer = 4;
                            p.sidebarChangeTimer = 2;
                            p.sidebarChange = 6;
                            p.sidebarChanging = true;
                        } else if (p.playerLevel[6] <= 20) {
                            p.sendMessage("You need 21 magic to cast this.");
                        }
                     
                    }
                }
            } else if (castSpell == 1178) {
                if (p.HasFireStaff()) {
                    if (!p.playerHasItemAmount(561, 1)) {
                        p.sendMessage("You do not have 1 nature.");
                    }
                    if (p.playerHasItemAmount(561, 1)) {
                        if (p.playerLevel[6] >= 55) {
                            p.deleteItem(castOnItem, castOnSlot, 1);
                            p.deleteItem(561, p.getItemSlot(561), 2);
                            p.addItem(995, 100);
                            p.addSkillXP((20 * p.playerLevel[6]), 6);
                            p.startAnimation(713);
                            p.gfx100(113);
                            p.frame174(223, 050, 000);
                            p.actionTimer = 4;
                            p.sidebarChangeTimer = 2;
                            p.sidebarChange = 6;
                            p.sidebarChanging = true;
                        } else if (p.playerLevel[6] <= 54) {
                            p.sendMessage("You need 55 magic to cast this.");
                        }
                    }
                } else if (!p.HasFireStaff()) {
                    if (!p.playerHasItemAmount(561, 2)
                            && !p.playerHasItemAmount(554, 5)) {
                        p.sendMessage("You do not have 2 nature and 5 fires.");
                    }
                    if (p.playerHasItemAmount(561, 2)
                            && p.playerHasItemAmount(554, 5)) {
                        if (p.playerLevel[6] >= 55) {
                            p.deleteItem(castOnItem, castOnSlot, 1);
                            p.deleteItem(561, p.getItemSlot(561), 2);
                            p.deleteItem(554, p.getItemSlot(554), 5);
                            p.addItem(995, 100);
                            p.addSkillXP((20 * p.playerLevel[6]), 6);
                            p.startAnimation(713);
                            p.gfx100(113);
                            p.frame174(223, 050, 000);
                            p.actionTimer = 4;
                            p.sidebarChangeTimer = 2;
                            p.sidebarChange = 6;
                            p.sidebarChanging = true;
                        } else if (p.playerLevel[6] <= 54) {
                            p.sendMessage(
                                    "You don't have high enough magic to cast this.");
                        }
                    }
                }
            } else if (castSpell == 1155) { // Enchant lvl 1(saph)
                if (p.playerLevel[6] >= 7) {
                    if (castOnItem == 1637) {
                        p.deleteItem(castOnItem, castOnSlot, 1);
                        p.addItem(2550, 1);
                        p.addSkillXP(18, 6);
                    } else if (castOnItem == 1656) {
                        p.deleteItem(castOnItem, castOnSlot, 1);
                        p.addItem(3853, 1);
                        p.addSkillXP(18, 6);
                    } else if (castOnItem == 1694) {
                        p.deleteItem(castOnItem, castOnSlot, 1);
                        p.addItem(1727, 1);
                        p.addSkillXP(18, 6);
                    } else {
                        p.sendMessage("This needs to be cast on Saphire Jewelry");
                    }
                } else {
                    p.sendMessage(
                            "You need atleast 7 Magic to cast Enchant Lvl-1 Jewelry");
                }
            } else if (castSpell == 1165) { // Enchant lvl 2(emme)
                if (p.playerLevel[6] >= 27) {
                    if (castOnItem == 1639) {
                        p.deleteItem(castOnItem, castOnSlot, 1);
                        p.addItem(2552, 1);
                        p.addSkillXP(37, 6);
                    } else if (castOnItem == 1658) {
                        p.deleteItem(castOnItem, castOnSlot, 1);
                        p.addItem(5521, 1);
                        p.addSkillXP(37, 6);
                    } else if (castOnItem == 1696) {
                        p.deleteItem(castOnItem, castOnSlot, 1);
                        p.addItem(1729, 1);
                        p.addSkillXP(37, 6);
                    } else {
                        p.sendMessage("This needs to be cast on Emerald Jewelry");
                    }
                } else {
                    p.sendMessage(
                            "You need atleast 27 Magic to cast Enchant Lvl-2 Jewelry");
                }
            } else if (castSpell == 1176) { // Enchant lvl 3(ruby)
                if (p.playerLevel[6] >= 49) {
                    if (castOnItem == 1641) {
                        p.deleteItem(castOnItem, castOnSlot, 1);
                        p.addItem(2568, 1);
                        p.addSkillXP(59, 6);
                    } else if (castOnItem == 1698) {
                        p.deleteItem(castOnItem, castOnSlot, 1);
                        p.addItem(1725, 1);
                        p.addSkillXP(59, 6);
                    } else {
                        p.sendMessage("This needs to be cast on Ruby Jewelry");
                    }
                } else {
                    p.sendMessage(
                            "You need atleast 49 Magic to cast Enchant Lvl-3 Jewelry");
                }
            } else if (castSpell == 1180) { // Enchant lvl 4(diam)
                if (p.playerLevel[6] >= 57) {
                    if (castOnItem == 1643) {
                        p.deleteItem(castOnItem, castOnSlot, 1);
                        p.addItem(2570, 1);
                        p.addSkillXP(67, 6);
                    } else if (castOnItem == 1700) {
                        p.deleteItem(castOnItem, castOnSlot, 1);
                        p.addItem(1731, 1);
                        p.addSkillXP(67, 6);
                    } else {
                        p.sendMessage("This needs to be cast on Diamond Jewelry");
                    }
                } else {
                    p.sendMessage(
                            "You need atleast 57 Magic to cast Enchant Lvl-4 Jewelry");
                }
            } else if (castSpell == 1187) { // Enchant lvl 5(drag)
                if (p.playerLevel[6] >= 68) {
                    if (castOnItem == 1645) {
                        p.deleteItem(castOnItem, castOnSlot, 1);
                        p.addItem(2572, 1);
                        p.addSkillXP(78, 6);
                    } else if (castOnItem == 1702) {
                        p.deleteItem(castOnItem, castOnSlot, 1);
                        p.addItem(1704, 1);
                        p.addSkillXP(78, 6);
                    } else {
                        p.sendMessage(
                                "This needs to be cast on Dragonstone Jewelry");
                    }
                } else {
                    p.sendMessage(
                            "You need atleast 68 Magic to cast Enchant Lvl-5 Jewelry");
                }
            }
        }
    }
}
